import indexConfig from '@/common/config.js'
let baseUrl = indexConfig.baseUrl
import { mapState, mapMutations } from 'vuex'
import { GetScreenshotsImage } from '@/api/index'
module.exports = {
	beforeCreate() {},
	data() {
		return {
			eqMode: this.$eqMode // "APP",
		}
	},
	methods: {
		...mapMutations({
			changTabsIndex: 'changTabsIndex'
		}),
		async emitPageData(pageUrl, className) {
			uni.showLoading({
				title: '正在截屏'
			})
			const urlpast = 'https://qz.qzqxw.com/qzapp/#/' + pageUrl
			console.info(`pageUrl:`, urlpast)
			const resp = await GetScreenshotsImage({
				url: urlpast,
				selector: className,
				device: 'Galaxy S8',
				quality: 100,
				milliseconds: 2000
			})
			if (resp.success) {
				const { data } = resp
				this.$hideLoading()
				let imgData = {
					url: data,
					isUrl: true
				}
				uni.webView.navigateTo({
					url: '/pages/share/share?data=' + encodeURIComponent(JSON.stringify(imgData))
				})
			} else {
				this.$hideLoading()
				// uni.showToast({
				//   icon: "error",
				//   title: "获取失败",
				// });
			}
		},
		changTabsIndexEv(jcIndex) {
			this.changTabsIndex(jcIndex)
		}
	},
	computed: {
		...mapState({
			eqData: (state) => state.tabBar.eqData,
			eqOtherData: (state) => state.tabBar.eqOtherData,
			tabsIndex: (state) => state.app.tabsIndex
		})
	},
	mounted() {
		this.eqMode = this.$eqMode
	}
}
